<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="船舶ID" prop="ShipID">
        <el-input
          v-model="queryParams.ShipID"
          placeholder="请输入船舶ID"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单编号" prop="OrderID">
        <el-input
          v-model="queryParams.OrderID"
          placeholder="请输入订单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:CarShip:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:CarShip:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:CarShip:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:CarShip:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="CarShipList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键ID" align="center" prop="id" />
      <el-table-column label="船舶ID" align="center" prop="ShipID" />
      <el-table-column label="来源，可能是一个状态标识" align="center" prop="Fromin" />
      <el-table-column label="海上移动服务标识码" align="center" prop="mmsi" />
      <el-table-column label="船舶类型" align="center" prop="shiptype" />
      <el-table-column label="国际海事组织的船舶识别码" align="center" prop="imo" />
      <el-table-column label="船舶名称" align="center" prop="name" />
      <el-table-column label="船舶呼号" align="center" prop="callsign" />
      <el-table-column label="船舶长度" align="center" prop="length" />
      <el-table-column label="船舶宽度" align="center" prop="width" />
      <el-table-column label="左舷距离" align="center" prop="left" />
      <el-table-column label="尾距" align="center" prop="trail" />
      <el-table-column label="船舶吃水深度" align="center" prop="draught" />
      <el-table-column label="目的地" align="center" prop="dest" />
      <el-table-column label="标准化后的目的地" align="center" prop="destStd" />
      <el-table-column label="目的港口代码" align="center" prop="destcode" />
      <el-table-column label="预计到达时间" align="center" prop="eta" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.eta, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="标准化后的预计到达时间" align="center" prop="etaStd" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.etaStd, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="航行状态标识" align="center" prop="navistat" />
      <el-table-column label="纬度" align="center" prop="lat" />
      <el-table-column label="经度" align="center" prop="lon" />
      <el-table-column label="速度" align="center" prop="sog" />
      <el-table-column label="船迹向" align="center" prop="cog" />
      <el-table-column label="船首向" align="center" prop="hdg" />
      <el-table-column label="转向率" align="center" prop="rot" />
      <el-table-column label="数据更新时间的时间戳" align="center" prop="lasttime" />
      <el-table-column label="订单编号" align="center" prop="OrderID" />
      <el-table-column label="订单来源" align="center" prop="OrderSource" />
      <el-table-column label="货源应到日期" align="center" prop="ArrivalDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.ArrivalDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="货源紧急程度" align="center" prop="UrgencyLevel" />
      <el-table-column label="货源发出地" align="center" prop="SourceLocation" />
      <el-table-column label="发出详细地址" align="center" prop="SourceAddress" />
      <el-table-column label="货源目的地" align="center" prop="DestinationLocation" />
      <el-table-column label="目的详细地址" align="center" prop="DestinationAddress" />
      <el-table-column label="计划装货时间" align="center" prop="LoadingPlanTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.LoadingPlanTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计划卸货时间" align="center" prop="UnloadingPlanTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.UnloadingPlanTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="货源类型" align="center" prop="CargoType" />
      <el-table-column label="货源现状" align="center" prop="CargoStatus" />
      <el-table-column label="装载方式" align="center" prop="LoadingMethod" />
      <el-table-column label="单托重量" align="center" prop="SinglePalletWeight" />
      <el-table-column label="单托体积" align="center" prop="SinglePalletVolume" />
      <el-table-column label="托数量" align="center" prop="PalletCount" />
      <el-table-column label="货源重量" align="center" prop="CargoWeight" />
      <el-table-column label="货源体积" align="center" prop="CargoVolume" />
      <el-table-column label="物料编码" align="center" prop="MaterialCode" />
      <el-table-column label="物料名称" align="center" prop="MaterialName" />
      <el-table-column label="规格型号" align="center" prop="SpecificationModel" />
      <el-table-column label="货源坐标" align="center" prop="CargoCoordinates" />
      <el-table-column label="货主名称" align="center" prop="OwnerName" />
      <el-table-column label="联系方式1" align="center" prop="Contact1" />
      <el-table-column label="接收方名称" align="center" prop="ReceiverName" />
      <el-table-column label="联系方式3" align="center" prop="Contact3" />
      <el-table-column label="审核状态" align="center" prop="ReviewStatus" />
      <el-table-column label="审核日期" align="center" prop="ReviewDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.ReviewDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审核人" align="center" prop="Reviewer" />
      <el-table-column label="拟定线路编号" align="center" prop="PlannedRouteID" />
      <el-table-column label="拟定线路名称" align="center" prop="PlannedRouteName" />
      <el-table-column label="中转地址" align="center" prop="TransferAddress" />
      <el-table-column label="拟定线路里程" align="center" prop="PlannedRouteMileage" />
      <el-table-column label="拟定车船编号" align="center" prop="PlannedVehicleShipNo" />
      <el-table-column label="车船条形码" align="center" prop="VehicleShipBarcode" />
      <el-table-column label="车船实时状态" align="center" prop="RealTimeVehicleShipStatus" />
      <el-table-column label="车船实时位置" align="center" prop="RealTimeVehicleShipLocation" />
      <el-table-column label="实时经度" align="center" prop="CurrentLongitude" />
      <el-table-column label="实时纬度" align="center" prop="CurrentLatitude" />
      <el-table-column label="实时路线" align="center" prop="RealTimeRoute" />
      <el-table-column label="管理单位" align="center" prop="ManagementUnit" />
      <el-table-column label="单位联系人" align="center" prop="UnitContactName" />
      <el-table-column label="联系人电话" align="center" prop="UnitContactPhone" />
      <el-table-column label="确定标记" align="center" prop="ConfirmationMark" />
      <el-table-column label="批准人" align="center" prop="Approver" />
      <el-table-column label="批准时间" align="center" prop="ApprovalTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.ApprovalTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="Remarks" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:CarShip:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:CarShip:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改车船调度对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="carshipRef" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="船舶ID" prop="ShipID">
          <el-input v-model="form.ShipID" placeholder="请输入船舶ID" />
        </el-form-item>
        <el-form-item label="海上移动服务标识码" prop="mmsi">
          <el-input v-model="form.mmsi" placeholder="请输入海上移动服务标识码" />
        </el-form-item>
        <el-form-item label="国际海事组织的船舶识别码" prop="imo">
          <el-input v-model="form.imo" placeholder="请输入国际海事组织的船舶识别码" />
        </el-form-item>
        <el-form-item label="船舶名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入船舶名称" />
        </el-form-item>
        <el-form-item label="船舶呼号" prop="callsign">
          <el-input v-model="form.callsign" placeholder="请输入船舶呼号" />
        </el-form-item>
        <el-form-item label="船舶长度" prop="length">
          <el-input v-model="form.length" placeholder="请输入船舶长度" />
        </el-form-item>
        <el-form-item label="船舶宽度" prop="width">
          <el-input v-model="form.width" placeholder="请输入船舶宽度" />
        </el-form-item>
        <el-form-item label="左舷距离" prop="left">
          <el-input v-model="form.left" placeholder="请输入左舷距离" />
        </el-form-item>
        <el-form-item label="尾距" prop="trail">
          <el-input v-model="form.trail" placeholder="请输入尾距" />
        </el-form-item>
        <el-form-item label="船舶吃水深度" prop="draught">
          <el-input v-model="form.draught" placeholder="请输入船舶吃水深度" />
        </el-form-item>
        <el-form-item label="目的地" prop="dest">
          <el-input v-model="form.dest" placeholder="请输入目的地" />
        </el-form-item>
        <el-form-item label="标准化后的目的地" prop="destStd">
          <el-input v-model="form.destStd" placeholder="请输入标准化后的目的地" />
        </el-form-item>
        <el-form-item label="目的港口代码" prop="destcode">
          <el-input v-model="form.destcode" placeholder="请输入目的港口代码" />
        </el-form-item>
        <el-form-item label="预计到达时间" prop="eta">
          <el-date-picker clearable
            v-model="form.eta"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择预计到达时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="标准化后的预计到达时间" prop="etaStd">
          <el-date-picker clearable
            v-model="form.etaStd"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择标准化后的预计到达时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="航行状态标识" prop="navistat">
          <el-input v-model="form.navistat" placeholder="请输入航行状态标识" />
        </el-form-item>
        <el-form-item label="纬度" prop="lat">
          <el-input v-model="form.lat" placeholder="请输入纬度" />
        </el-form-item>
        <el-form-item label="经度" prop="lon">
          <el-input v-model="form.lon" placeholder="请输入经度" />
        </el-form-item>
        <el-form-item label="速度" prop="sog">
          <el-input v-model="form.sog" placeholder="请输入速度" />
        </el-form-item>
        <el-form-item label="船迹向" prop="cog">
          <el-input v-model="form.cog" placeholder="请输入船迹向" />
        </el-form-item>
        <el-form-item label="船首向" prop="hdg">
          <el-input v-model="form.hdg" placeholder="请输入船首向" />
        </el-form-item>
        <el-form-item label="转向率" prop="rot">
          <el-input v-model="form.rot" placeholder="请输入转向率" />
        </el-form-item>
        <el-form-item label="数据更新时间的时间戳" prop="lasttime">
          <el-input v-model="form.lasttime" placeholder="请输入数据更新时间的时间戳" />
        </el-form-item>
        <el-form-item label="订单编号" prop="OrderID">
          <el-input v-model="form.OrderID" placeholder="请输入订单编号" />
        </el-form-item>
        <el-form-item label="订单来源" prop="OrderSource">
          <el-input v-model="form.OrderSource" placeholder="请输入订单来源" />
        </el-form-item>
        <el-form-item label="货源应到日期" prop="ArrivalDate">
          <el-date-picker clearable
            v-model="form.ArrivalDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择货源应到日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="货源紧急程度" prop="UrgencyLevel">
          <el-input v-model="form.UrgencyLevel" placeholder="请输入货源紧急程度" />
        </el-form-item>
        <el-form-item label="货源发出地" prop="SourceLocation">
          <el-input v-model="form.SourceLocation" placeholder="请输入货源发出地" />
        </el-form-item>
        <el-form-item label="发出详细地址" prop="SourceAddress">
          <el-input v-model="form.SourceAddress" placeholder="请输入发出详细地址" />
        </el-form-item>
        <el-form-item label="货源目的地" prop="DestinationLocation">
          <el-input v-model="form.DestinationLocation" placeholder="请输入货源目的地" />
        </el-form-item>
        <el-form-item label="目的详细地址" prop="DestinationAddress">
          <el-input v-model="form.DestinationAddress" placeholder="请输入目的详细地址" />
        </el-form-item>
        <el-form-item label="计划装货时间" prop="LoadingPlanTime">
          <el-date-picker clearable
            v-model="form.LoadingPlanTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择计划装货时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划卸货时间" prop="UnloadingPlanTime">
          <el-date-picker clearable
            v-model="form.UnloadingPlanTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择计划卸货时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="装载方式" prop="LoadingMethod">
          <el-input v-model="form.LoadingMethod" placeholder="请输入装载方式" />
        </el-form-item>
        <el-form-item label="单托重量" prop="SinglePalletWeight">
          <el-input v-model="form.SinglePalletWeight" placeholder="请输入单托重量" />
        </el-form-item>
        <el-form-item label="单托体积" prop="SinglePalletVolume">
          <el-input v-model="form.SinglePalletVolume" placeholder="请输入单托体积" />
        </el-form-item>
        <el-form-item label="托数量" prop="PalletCount">
          <el-input v-model="form.PalletCount" placeholder="请输入托数量" />
        </el-form-item>
        <el-form-item label="货源重量" prop="CargoWeight">
          <el-input v-model="form.CargoWeight" placeholder="请输入货源重量" />
        </el-form-item>
        <el-form-item label="货源体积" prop="CargoVolume">
          <el-input v-model="form.CargoVolume" placeholder="请输入货源体积" />
        </el-form-item>
        <el-form-item label="物料编码" prop="MaterialCode">
          <el-input v-model="form.MaterialCode" placeholder="请输入物料编码" />
        </el-form-item>
        <el-form-item label="物料名称" prop="MaterialName">
          <el-input v-model="form.MaterialName" placeholder="请输入物料名称" />
        </el-form-item>
        <el-form-item label="规格型号" prop="SpecificationModel">
          <el-input v-model="form.SpecificationModel" placeholder="请输入规格型号" />
        </el-form-item>
        <el-form-item label="货源坐标" prop="CargoCoordinates">
          <el-input v-model="form.CargoCoordinates" placeholder="请输入货源坐标" />
        </el-form-item>
        <el-form-item label="货主名称" prop="OwnerName">
          <el-input v-model="form.OwnerName" placeholder="请输入货主名称" />
        </el-form-item>
        <el-form-item label="联系方式1" prop="Contact1">
          <el-input v-model="form.Contact1" placeholder="请输入联系方式1" />
        </el-form-item>
        <el-form-item label="接收方名称" prop="ReceiverName">
          <el-input v-model="form.ReceiverName" placeholder="请输入接收方名称" />
        </el-form-item>
        <el-form-item label="联系方式3" prop="Contact3">
          <el-input v-model="form.Contact3" placeholder="请输入联系方式3" />
        </el-form-item>
        <el-form-item label="审核日期" prop="ReviewDate">
          <el-date-picker clearable
            v-model="form.ReviewDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择审核日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="审核人" prop="Reviewer">
          <el-input v-model="form.Reviewer" placeholder="请输入审核人" />
        </el-form-item>
        <el-form-item label="拟定线路编号" prop="PlannedRouteID">
          <el-input v-model="form.PlannedRouteID" placeholder="请输入拟定线路编号" />
        </el-form-item>
        <el-form-item label="拟定线路名称" prop="PlannedRouteName">
          <el-input v-model="form.PlannedRouteName" placeholder="请输入拟定线路名称" />
        </el-form-item>
        <el-form-item label="中转地址" prop="TransferAddress">
          <el-input v-model="form.TransferAddress" placeholder="请输入中转地址" />
        </el-form-item>
        <el-form-item label="拟定线路里程" prop="PlannedRouteMileage">
          <el-input v-model="form.PlannedRouteMileage" placeholder="请输入拟定线路里程" />
        </el-form-item>
        <el-form-item label="拟定车船编号" prop="PlannedVehicleShipNo">
          <el-input v-model="form.PlannedVehicleShipNo" placeholder="请输入拟定车船编号" />
        </el-form-item>
        <el-form-item label="车船条形码" prop="VehicleShipBarcode">
          <el-input v-model="form.VehicleShipBarcode" placeholder="请输入车船条形码" />
        </el-form-item>
        <el-form-item label="车船实时位置" prop="RealTimeVehicleShipLocation">
          <el-input v-model="form.RealTimeVehicleShipLocation" placeholder="请输入车船实时位置" />
        </el-form-item>
        <el-form-item label="实时经度" prop="CurrentLongitude">
          <el-input v-model="form.CurrentLongitude" placeholder="请输入实时经度" />
        </el-form-item>
        <el-form-item label="实时纬度" prop="CurrentLatitude">
          <el-input v-model="form.CurrentLatitude" placeholder="请输入实时纬度" />
        </el-form-item>
        <el-form-item label="实时路线" prop="RealTimeRoute">
          <el-input v-model="form.RealTimeRoute" placeholder="请输入实时路线" />
        </el-form-item>
        <el-form-item label="管理单位" prop="ManagementUnit">
          <el-input v-model="form.ManagementUnit" placeholder="请输入管理单位" />
        </el-form-item>
        <el-form-item label="单位联系人" prop="UnitContactName">
          <el-input v-model="form.UnitContactName" placeholder="请输入单位联系人" />
        </el-form-item>
        <el-form-item label="联系人电话" prop="UnitContactPhone">
          <el-input v-model="form.UnitContactPhone" placeholder="请输入联系人电话" />
        </el-form-item>
        <el-form-item label="确定标记" prop="ConfirmationMark">
          <el-input v-model="form.ConfirmationMark" placeholder="请输入确定标记" />
        </el-form-item>
        <el-form-item label="批准人" prop="Approver">
          <el-input v-model="form.Approver" placeholder="请输入批准人" />
        </el-form-item>
        <el-form-item label="批准时间" prop="ApprovalTime">
          <el-date-picker clearable
            v-model="form.ApprovalTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择批准时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="Remarks">
          <el-input v-model="form.Remarks" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listCarShip, getSingleCarShip,getCarShip, delCarShip, addCarShip, updateCarShip } from "@/api/system/CarShip";

export default {
  name: "CarShip",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 车船调度表格数据
      CarShipList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ShipID: null,
        OrderID: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        ShipID: [
          { required: true, message: "船舶ID不能为空", trigger: "blur" }
        ],
        mmsi: [
          { required: true, message: "海上移动服务标识码不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询单船信息 */
    getSingleCarShipInfo() {
      this.loading = true;
      getSingleCarShip(this.queryParams.ShipID).then(response => {
        this.form = response.data;
        this.CarShipList = [response.data]; // 仅展示单船信息
        this.total = 1;
        this.loading = false;
      }).catch(() => {
        this.loading = false;
      });
    },
    /** 查询车船调度列表 */
    getList() {
      this.loading = true;
      listCarShip(this.queryParams).then(response => {
        this.CarShipList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        ShipID: null,
        Fromin: null,
        mmsi: null,
        shiptype: null,
        imo: null,
        name: null,
        callsign: null,
        length: null,
        width: null,
        left: null,
        trail: null,
        draught: null,
        dest: null,
        destStd: null,
        destcode: null,
        eta: null,
        etaStd: null,
        navistat: null,
        lat: null,
        lon: null,
        sog: null,
        cog: null,
        hdg: null,
        rot: null,
        lasttime: null,
        OrderID: null,
        OrderSource: null,
        ArrivalDate: null,
        UrgencyLevel: null,
        SourceLocation: null,
        SourceAddress: null,
        DestinationLocation: null,
        DestinationAddress: null,
        LoadingPlanTime: null,
        UnloadingPlanTime: null,
        CargoType: null,
        CargoStatus: null,
        LoadingMethod: null,
        SinglePalletWeight: null,
        SinglePalletVolume: null,
        PalletCount: null,
        CargoWeight: null,
        CargoVolume: null,
        MaterialCode: null,
        MaterialName: null,
        SpecificationModel: null,
        CargoCoordinates: null,
        OwnerName: null,
        Contact1: null,
        ReceiverName: null,
        Contact3: null,
        ReviewStatus: null,
        ReviewDate: null,
        Reviewer: null,
        PlannedRouteID: null,
        PlannedRouteName: null,
        TransferAddress: null,
        PlannedRouteMileage: null,
        PlannedVehicleShipNo: null,
        VehicleShipBarcode: null,
        RealTimeVehicleShipStatus: null,
        RealTimeVehicleShipLocation: null,
        CurrentLongitude: null,
        CurrentLatitude: null,
        RealTimeRoute: null,
        ManagementUnit: null,
        UnitContactName: null,
        UnitContactPhone: null,
        ConfirmationMark: null,
        Approver: null,
        ApprovalTime: null,
        Remarks: null
      };
      if (this.$refs.carshipRef) {
        this.$refs.carshipRef.resetFields();
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      if (this.queryParams.ShipID) {
        this.getSingleCarShipInfo(); // 查询单船
      } else {
        this.queryParams.pageNum = 1;
        this.getList(); // 查询多个船舶
      }
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加车船调度";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getCarShip(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改车船调度";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs.carshipRef.validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateCarShip(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addCarShip(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除车船调度编号为"' + ids + '"的数据项？').then(function() {
        return delCarShip(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/CarShip/export', {
        ...this.queryParams
      }, `CarShip_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
